import Vue from 'vue';

// 初始化音频播放组件
const scan = (successCallback, failCallback) => {
	uni.scanCode({
		success: res => {
			Vue.prototype.$playScanSuccess();
			successCallback && successCallback instanceof Function && successCallback(res.result);
		},
		fail: res => {
			if (res.errMsg !== 'scanCode:fail cancel') {
				Vue.prototype.$playScanFail();
				failCallback && failCallback instanceof Function && failCallback();
			}
		}
	});
}

export default scan
